package com.example.mapper;

import com.example.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
    //@Select("select e.*,d.name as dept_name from emp e left join dept d on e.dept_id = d.id")
    List<Emp> getAllEmps(@Param("name") String name,
                         @Param("gender") Integer gender,
                         @Param("begin") LocalDate begin,
                         @Param("end") LocalDate end);
    @Select("select * from emp")
    List<Emp> getAllEmpList();

    List<Map<String, Object>> countEmpJobData();

    @MapKey("name")
    List<Map> countEmpGenderData();

    void deleteEmpById(@Param("ids") List<Integer> ids);

    Emp getEmpById(@Param("id") Integer id);

    void updateById(Emp emp);
    @Select("select * from emp where dept_id = #{deptId}")
    List<Emp> getEmpsByDeptId(@Param("deptId") Integer deptId);

    /**
     * 根据用户名和密码查询员工信息
     */
    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp getUsernameAndPassword(Emp emp);

    void addEmp(Emp emp);
}
